<?php
require __DIR__.'/../../../vendor/autoload.php';

use Gateway\app\rpverifyExt\UploadIDIMGRequest;
use Gateway\CommUtil;
use Gateway\ESGateway;
use Gateway\JSONUtil;
use Gateway\Log;


$appCode = "d2808c1338ce01f3e3efdb486f9effb9";
$algo = "3";
$key = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhdQdw6uTGz+X4e+/eGpu4dcKrfrjQAe0tTQyn6TuKBobcsUsESkx9jcCeG4cpuxmN8jNeDAZsbTujNLD/aYl2g==";
$esGateway = new ESGateway($appCode, $algo, $key);

$path = 'resources'.DIRECTORY_SEPARATOR.'cn_idcard.jpeg';//拼接路径
$imageData =file_get_contents($path);
$base64String  = base64_encode($imageData);
$uploadIDIMGRequest = new UploadIDIMGRequest();
$uploadIDIMGRequest->bizId = CommUtil::getTimeUUID();
$uploadIDIMGRequest->IDImg =$base64String ;
$uploadIDIMGRequest->countryISOCode = "US";
$uploadIDIMGRequest->IDType = "passport";
$uploadIDIMGRequest->IDNumber = "102020000000";
$uploadIDIMGRequest->name = "PONY";

$gatewayResponse = $esGateway->sendToGateWay(UploadIDIMGRequest::$act,$uploadIDIMGRequest->toJsonStr());
Log::DEBUG("服务器返回数据：".$gatewayResponse->toJsonStr());
if ($gatewayResponse->bizContent != null) {
    Log::DEBUG("业务数据为：".$gatewayResponse->bizContent);
    $rsp = JSONUtil::fromJsonStr($gatewayResponse->bizContent);
}

